from scipy import ceil
import sys

class progressbar():
  def __init__(self,lenf,text="Loading %i files"):
    self.condition=(1+lenf/100)
    tmp = text % lenf
    nb = (lenf/(1+lenf/100))
    print "[" + " "*((nb-len(tmp))/2) +tmp+" "*ceil((nb-len(tmp))/2.) + "]"
    sys.stdout.write(' ')
    self.i=0
  def __call__(self):
    self.i+=1
    if ((self.i%self.condition) == 0):
      sys.stdout.write('+')
      sys.stdout.flush()